package com.skycode7.dao;

import com.skycode7.util.DBconnection;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class AdminDao {
    DBconnection DBConn = new DBconnection();
    public boolean CheckLogin(String s1,String s2) throws SQLException {
        Connection conn = DBConn.getConn();//获取MySql连接
        Statement statement = conn.createStatement();// 获取处理对象
        ResultSet rs = null;//声明结果集对象
        boolean OK = true;
        String sql = "select * from admin where AdminName = '" + s1 +
                "' and AdminPwd = '" + s2 + "'";//查询账户密码语句
        rs = statement.executeQuery(sql);//执行sql查询
        if (!rs.next()) {//如果没查出数据 没有该用户
            OK = false;
        }else{
            OK = true;//表示有该用户
            // todo 后期需要添加账户密码严格验证
        }
        return OK;
    }
}
